package Reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class ReflectDemo6 {
    public static void main(String[] args) throws Exception {
        Class cla=Class.forName("Reflect.Person");
        Method method=cla.getMethod("say", String.class, int.class);

        String name=method.getName();
        System.out.println("方法名"+cla.getName());
//        System.out.println("方法名"+method.getName());
        Class returnType=method.getReturnType();
        System.out.println("方法返回值"+returnType);
//        System.out.println("方法返回值"+method.getReturnType());
        int count=method.getParameterCount();
        System.out.println("方法参数个数"+count);
//        System.out.println("方法参数个数"+method.getParameterCount());
        Class[] parameterTypes=method.getParameterTypes();
        for (Class parameterType:parameterTypes){
            System.out.println("方法参数类型"+parameterType);
        }
        int modifiers=method.getModifiers();
        switch (modifiers){
            case Modifier.PUBLIC:
                System.out.println("方法修饰符"+"public");
                break;
            case Modifier.PRIVATE:
                System.out.println("方法修饰符"+"private");
                break;
            case Modifier.PROTECTED:
                System.out.println("方法修饰符"+"protected");
                break;
            default:
                System.out.println("方法修饰符"+"default");
        }
    }
}
